﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace BookNet
{
    public partial class _default : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.IsAuthenticated)
                Response.Redirect("login.aspx");
            name.Text = Page.User.Identity.Name;
        }

        protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
            // Get a reference to the currently logged on user
            MembershipUser currentUser = Membership.GetUser();

            // Determine the currently logged on user's UserId value
            Guid currentUserId = (Guid)currentUser.ProviderUserKey;

            // Assign the currently logged on user's UserId to the @UserId parameter
            e.Command.Parameters["@Seller"].Value = currentUserId; 
        }

        protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
            // Get a reference to the currently logged on user
            MembershipUser currentUser = Membership.GetUser();

            // Determine the currently logged on user's UserId value
            Guid currentUserId = (Guid)currentUser.ProviderUserKey;

            // Assign the currently logged on user's UserId to the @UserId parameter
            e.Command.Parameters["@ID"].Value = currentUserId; 
        }

        protected void SearchButton_Click(object sender, EventArgs e)
        {
            TextBox keyword = (TextBox)FindControl("SearchBox");
            Response.Redirect("SearchBook.aspx?keyword=" + keyword.Text);
        }
    }
}
